package NetWork;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-10-21
 * Time: 9:28
 */
public class UdpDictServer extends UdpEchoServer{
    //只需要重写UdpEchoServer中的数据处理方法即可
    private Map<String,String> dict = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict.put("小米","MIUI");
        dict.put("苹果","apple");
        dict.put("蓝色","blue");
    }
    @Override
    public String functor(String recvStr){
        return dict.getOrDefault(recvStr,"Not Found");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.Start();
    }
}
